package io.renren.modules.weldingmachine.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.weldingmachine.entity.WeldingmachineEntity;
import io.renren.modules.weldingmachine.service.WeldingmachineService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-04 16:38:08
 */
@RestController
@RequestMapping("weldingmachine/weldingmachine")
public class WeldingmachineController {
    @Autowired
    private WeldingmachineService weldingmachineService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("weldingmachine:weldingmachine:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = weldingmachineService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{no}")
   // @RequiresPermissions("weldingmachine:weldingmachine:info")
    public R info(@PathVariable("no") Integer no){
		WeldingmachineEntity weldingmachine = weldingmachineService.getById(no);

        return R.ok().put("weldingmachine", weldingmachine);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("weldingmachine:weldingmachine:save")
    public R save(@RequestBody WeldingmachineEntity weldingmachine){
		weldingmachineService.save(weldingmachine);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("weldingmachine:weldingmachine:update")
    public R update(@RequestBody WeldingmachineEntity weldingmachine){
		weldingmachineService.updateById(weldingmachine);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("weldingmachine:weldingmachine:delete")
    public R delete(@RequestBody Integer[] nos){
		weldingmachineService.removeByIds(Arrays.asList(nos));

        return R.ok();
    }

}
